package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {
	engine := gin.Default()

	// POST
	engine.POST("/register", func(context *gin.Context) {
		path := context.FullPath()
		fmt.Println(path)

		var register Register
		err := context.ShouldBind(&register)
		if err != nil {
			log.Fatal(err.Error())
			return
		}
		fmt.Println(register.UserName)
		fmt.Println(register.Phone)
		fmt.Println(register.Password)

		context.String(http.StatusOK, "hello ,"+register.UserName)

	})

	engine.Run()
}

type Register struct {
	UserName string `json:"username,omitempty" xml:"username" form:"username"`
	Phone    string `json:"phone,omitempty" xml:"phone" form:"phone"`
	Password string `json:"password,omitempty" xml:"password" form:"password"`
}
